<?php

function str_substr($start, $end, $str) // 字符串截取函数     
{     
    $temp = explode($start, $str, 2);     
    $content = explode($end, $temp[1], 2);     
    return $content[0];     
} 
function strtr_words($str)//同义词替换
{
    $words=array();
    $content = file_get_contents('/alidata/www/xinjieco/auto/same.txt');//词库
    $content = str_replace( "\r", "",$content); //去掉换行符(以便兼容Linux主机)
    $content = preg_split('/\n/', $content, -1, PREG_SPLIT_NO_EMPTY);//\n分割字符
        foreach($content as $k=>$v)
        {
            if($k!=0)
            {
                $str_data = explode('=',$v);//关键词分割符
                $words+=array("$str_data[0]"=>"$str_data[1]");
            }
        }
    return strtr($str,$words);//返回结果
}